package com.study.mike.model.entity;

import java.io.Serializable;
import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.*;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.mike.common.annotation.EncryptField;
import com.study.mike.common.enums.BookStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author KangHui
 * @since 2022-07-08
 */
@Data
@Accessors(chain = true)
@TableName("book")
public class Book implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 书名
     */
    @TableField(value = "book_name")
    private String bookName;

    /**
     * 编号
     */
    @TableField("book_no")
    @NotBlank(message = "数据编号不能为空！")
    @EncryptField
    private String bookNo;

    /**
     * 价格
     */
    @TableField(value = "book_price")
    private BigDecimal bookPrice;

    /**
     * 作者
     */
    @TableField(value = "book_author")
    @EncryptField
    private String bookAuthor;

    /**
     * 出版日期
     */
    @TableField(value = "book_time")
    private Date bookTime;

    /**
     * 状态0禁用、1启用
     */
    @TableField(value = "status")
    private BookStatusEnum status;

    /**
     * 创建日期
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新日期
     */
    @TableField(value = "update_time", fill = FieldFill.UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 是否删除0存在，1删除
     */
    @TableLogic
    @TableField(value = "delete_flag")
    private Long deleteFlag;

    /**
     * 测试
     */
    @TableField("raw_data")
    private String rawData;
}
